package me.xiaoyan.java.spring.mapper;

import me.xiaoyan.java.spring.po.Link;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LinkMapper {

    public void insert(Link link);
    @Results(id="linkMap",value = {
            @Result(property = "visitCount",column = "visit_count")
    })
    @Select("select * from links order by id desc limit #{count}")
    public List<Link> select(int count);

    /**
     * 根据id查询链接
     * @param id
     * @return
     */
    @ResultMap("linkMap")
    @Select("select * from links where id= #{id}")
    Link selectById(Integer id);

    public void update(Link link);
}
